package com.yuncheng.spcyApi.constant.schedule;

import com.yuncheng.spcyApi.scheduleJob.SpringConUtils;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * 定时任务 - 静态变量
 */
public class ScheduleConstant {
//    private static final Logger log = LoggerFactory.getLogger(ScheduleConstant.class);

    public static final String Job_Basic_Success = "成功";
    public static final String Job_Basic_Error = "失败";

    // 定时任务-任务名称
    public static final String rw_name_getXzspData_Method = "getXzspData";
    public static final String rw_name_getXzspData = "获取行政审批数据-定时任务";

    // 行政审批数据-推送任务受理信息
    public static final String Xzsp_Data_Rwsl_Name = "行政审批数据-推送任务受理信息";
    public static final String Xzsp_Data_Rwsl_Code = "1";
    public static final String Xzsp_Data_Rwsl_Method = "pushXzspDataByRwsl";

    // 行政审批数据-推送审查结论信息
    public static final String Xzsp_Data_Scjl_Name = "行政审批数据-推送审查结论信息";
    public static final String Xzsp_Data_Scjl_Code = "2";
    public static final String Xzsp_Data_Scjl_Method = "pushXzspDataByScjl";

    // 行政审批数据-推送材料附件信息
    public static final String Xzsp_Data_Fjcl_Name = "行政审批数据-推送材料附件信息";
    public static final String Xzsp_Data_Fjcl_Code = "3";
    public static final String Xzsp_Data_Fjcl_Code_Method = "pushXzspDataByClfj";

    // 政审批数据 - 推送审评流转办理意见接口
    public static final String Xzsp_Data_Lzjl_Name = "行政审批数据-推送审评流转办理意见接口";
    public static final String Xzsp_Data_Lzjl_Code = "4";
    public static final String Xzsp_Data_Lzjl_Method = "pushSpJobLzjl";

    // 计算申请事项-从受理到移送之间的天数
    public static final String Xzsp_Data_Computed_Slts_Name = "行政审批数据-计算申请事项-从受理到移送之间的天数";
    public static final String Xzsp_Data_Computed_Slts_Code_Method = "computeSqsxAcceptedDays";

    // 定时任务-删除已经移送的申请事项在本地生成的文件
    public static final String Delete_Sqsx_Local_Wjjl_Name = "定时任务-删除已经移送的申请事项在本地生成的文件";
    public static final String Delete_Sqsx_Local_Wjjl_Method = "deleteSqsxLocalWjjl";

    // 定时任务bean对象
    public static final String Bean_Spcy_Schedule_Task = "spcyScheduleTask";

    // 定时任务 - 发送短信 - 方法名
    public static final String Schedule_Task_Name = "定时任务-发送短信";
    public static final String Schedule_Task_SMS = "smsScheduleJob";

    // 定时任务-党务会议计划
    public static final String Schedule_Task_Dwhyjh = "syncDwhyjh";

    // 定时任务-申请事项自动选派人员
    public static final String Schedule_Task_Sqsx_Auto_Xpry = "sqsxAutoXpry";

    // 定时任务-发送选派人员短信过期确认
    public static final String Schedule_Task_Expire_Xpry_Qr_Sms = "expireXpryQrSms";
    public static final int Schedule_Task_Expire_Xpry_Qr_Sms_Cron_Miu = 30; // 定时任务时间,30分钟后执行

    // 定时认为 - cron表达式 - 每天凌晨0点,1点,2点
    public static final String Cron_Computed_Accepts_Days = "0 0 1 * * ?";
    public static String Cron_Delete_Temp_File = "0 0 2 * * ?";

    // 定时任务类Root路径
    public static String Schedule_Root_class_Url = "com.yuncheng.scheduleJob.";

    // 获取定时任务的所有bean
    public static List<String> getScheduleBeanList(){
        List<String> beanList = new ArrayList<>();
        beanList.add(ScheduleConstant.Bean_Spcy_Schedule_Task);

        return beanList;
    }

    // 判断bean中，是否存在该方法
    public static boolean getBeanInMethod(String bean,String method){
        boolean isExist = false;
        /*Class<?> aClass = null;
        try {
           aClass = Class.forName(Schedule_Root_class_Url + StringPatternUtils.getStringWithFirstUpperCase(ScheduleConstant.Bean_Spcy_Schedule_Task));
        } catch (ClassNotFoundException e) {
            log.error("将字符串转为Class出错，{}",e.getMessage());
        }*/

        if (ScheduleConstant.Bean_Spcy_Schedule_Task.equals(bean)){
            Method[] declaredMethods = SpringConUtils.getBean(bean).getClass().getDeclaredMethods();
            for (Method m : declaredMethods){
//                System.out.println(m.getName());
                if (m.getName().equals(method)){
                    isExist = true;
                    break;
                }
            }
        }else {
            isExist = false;
        }
        return isExist;
    }
}
